﻿@if (ViewBag.menus != null)
{
    foreach (var menu in ViewBag.menus)
    {
        var num = menu.Child.Count;
        <li class="@(menu.IsTopClickMenu == 0 ? "treeview" : "") @(ViewBag.activeMenuPid==menu.Id?"menu-open":"")">
            <a href="@(menu.IsTopClickMenu == 1 ? menu.Url: "")">
                <i class="@menu.Icon"></i>
                <span>@menu.Name</span>
                @{ if (menu.IsTopClickMenu == 0 && num > 0)
                    {
                        <span class="pull-right-container">
                            <i class="fa fa-angle-left pull-right"></i>
                        </span>
                    }
                }
            </a>
            @{ if (num > 0 && menu.IsTopClickMenu == 0)
                {
                    <ul class="treeview-menu" style="@(ViewBag.activeMenuPid==menu.Id?"display:block":"")">
                        @foreach (var chi in menu.Child)
                        {
                            <li class="@(ViewBag.activeMenuCid==chi.Id?"active":"")"><a href="@(chi.Url)"><i class="@chi.Icon"></i> @chi.Name</a></li>
                        }
                    </ul>
                }
            }
        </li>
    }
}
